'use strict';

const BaseService = require('./base');

class AnnouncementService extends BaseService {
  constructor(ctx) {
    super(ctx, 'Announcement');
  }
  
  // 获取活跃的公告
  async getActiveAnnouncements(where) {
    return this.ctx.model.Announcement.findAll({
      where,
      order: [
        ['is_top', 'DESC'], // 置顶的排在前面
        ['create_time', 'DESC'] // 按创建时间倒序
      ]
    });
  }
}

module.exports = AnnouncementService;
